from app.models.AdItems import AdItems
from schemas.ad_items import Create, Update


class AdItemsServices:
    @staticmethod
    def create(form: Create):
        data = AdItems.create(**form.model_dump())
        return data

    @staticmethod
    def get_all(current, size):
        data = AdItems.paginate(size, current)
        return data

    @staticmethod
    def get_one(Id: int):
        data = AdItems.find(Id)
        return data

    @staticmethod
    def update(form: Update,item_id:str):
        data = AdItems.find(item_id)
        data.update(form.dict())
        return data

    @staticmethod
    def delete(Id):
        data = AdItems.find(Id)
        data.delete()
        return data


